
<%@page import="dto.DTO_KhachHang"%>
<%@page import="dto.DTO_KhachHang"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">
<%@taglib uri="/struts-tags" prefix="s" %>
<%
    if(session.getAttribute("KhachHang") == null)
    {
            response.sendRedirect("dangnhap.jsp");
    }
    else
    {
           dto.DTO_KhachHang kh = new DTO_KhachHang();
           kh = (DTO_KhachHang)session.getAttribute("KhachHang");
           if(kh.getQuyenHan()!= 1)
               {
                    response.sendRedirect("dangnhap.jsp");
               }
    }

%>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Quản Lý Sản Phẩm</title>
        <link type="text/css" rel="stylesheet" href="css/style.css" />
        <script type="text/javascript" src="js/jquery-1.5.2.js"></script>
        <script type="text/javascript" src="js/myJS.js"></script>
        <script type="text/javascript" src="js/jquery.nivo.slider.pack.js"></script>

    </head>
    <body>
         <div id="top-background">
             <div id="page-container">
                 <jsp:include page="template/header.jsp"></jsp:include>
                 <jsp:include page="template/adminpage_menu.jsp"></jsp:include>
                 <div id="main-content">
                     <div style="padding: 10px;">
                          <h2 style="color:#0099ff;">Bộ lọc</h2><br>
                         <s:form action="QLSanPham.action" method="POST" cssStyle="padding:0px 10px 10px 0px;" theme="simple">
                             <table>
                                 <tr>
                                     <td>
                                         <h4 style="color:#0099ff;">Tìm kiếm theo</h4>
                                     </td>
                                     <td>
                                         <s:select list="#{'1':'MãSP','2':'TênSP','3':'Tất cả'}" name="chon"></s:select>
                                     </td>
                                 </tr>
                                  <tr>
                                     <td>
                                         <h4 style="color:#0099ff;">Giá trị tìm kiếm </h4>
                                     </td>
                                     <td>
                                          <s:textfield name="gtTimKiem" ></s:textfield>
                                     </td>
                                 </tr>
                                 <tr>
                                      <td>

                                     </td>
                                    <td>
                                        <s:submit name="btnTimKiem" value="Tìm kiếm"></s:submit>
                                     </td>

                                 </tr>
                                 <tr>
                                     <td colspan="2">
                                         <s:actionerror cssStyle="color:red;" />
                                     </td>
                                 </tr>

                             </table>
                         </s:form>
                     </div>
                     <h2><a id="clickaddsp" style="cursor: pointer;color:#0099ff; padding: 10px;">Thêm sản phẩm mới</a></h2>
                     <s:label value="" name="thongbao"></s:label>
                     <div id="addsp" style="padding: 10px;">
                        <s:form action="ThemSanPham.action" method="POST" theme="simple">
                         <table width="100%;" border="1" id="khachhang">
                             <tr>
                                 <td>
                                     <p style="background-color: #4a4a4a;color: #0099ff;">Tên sản phẩm</p>
                                 </td>
                                 <td>
                                     <s:textfield name="TenSP" theme="simple"></s:textfield>
                                 </td>
                                  <td>
                                     <p style="background-color: #4a4a4a;color: #0099ff;">Giá mua</p>
                                 </td>
                                 <td>
                                     <s:textfield name="GiaMua" theme="simple" ></s:textfield>
                                 </td>
                                  <td>
                                     <p style="background-color: #4a4a4a;color: #0099ff;">Giá bán</p>
                                 </td>
                                 <td>
                                      <s:textfield name="GiaBan" theme="simple" ></s:textfield>
                                 </td>
                             </tr>
                              <tr>
                                
                                 <td>
                                     <p stylebackground-color: #4a4a4a;color: #0099ff;">Loại sản phẩm</p>
                                 </td>
                                 <td>
                                     <s:select  list="#{'0':'Áo Thun', '1':'Áo SơMi', '2':'Áo Khoác','3':'Quần jean','4':'Áo kaki','5':'Váy'}" name = "LoaiSP" cssStyle="width:142px" theme="simple" />
                                 </td>
                                  <td>
                                     <p style="color: #0099ff;">Chủ đề</p>
                                 </td>
                                 <td>
                                     <s:select  list="#{'0':'Nổi bật', '1':'Mới', '2':'Khuyến Mãi'}" name = "ChuDe" cssStyle="width:142px" theme="simple"/>
                                 </td>
                                  <td>
                                     <p style="background-color: #4a4a4a;color: #0099ff;">Giới tính</p>
                                 </td>
                                 <td>
                                      <s:select list="#{'0':'Nữ', '1':'Nam'}" name = "GioiTinh" cssStyle="width:142px" theme="simple" />
                                 </td>
                             </tr>
                             <tr>
                                  <td >
                                     <p style="background-color: #4a4a4a;color: #0099ff;">Hình ảnh</p>
                                 </td>
                                 <td colspan="3">
                                     <s:textfield name="HinhAnh" theme="simple"  cssStyle="width:100%;"></s:textfield>
                                 </td>
                             </tr>
                             <tr>
                                 <td>
                                     <p style="background-color: #4a4a4a;color: #0099ff;">Thông tin</p>
                                 </td>
                                 <td colspan="3">
                                     <s:textarea name="ThongTin" theme="simple"  cssStyle="width:100%;"></s:textarea>
                                 </td>
                                 <td>
                                     <s:hidden name = "chon" value="%{chon}"></s:hidden>
                                     <s:hidden name = "gtTimKiem" value="%{gtTimKiem}"></s:hidden>
                                     <s:submit name="btnThem" value="Thêm sản phẩm" theme="simple"></s:submit>
                                 </td>
                             </tr>
                             <tr>
                                 <td colspan="6" bgcolor="black" height="10px">

                                 </td>
                             </tr>
                         </table>
                     </s:form>
                     </div>
                     <div style="padding: 10px;">
                       <h2 style="color: #0099ff;">Danh sách sản phẩm</h2>
                       <s:iterator value="dssp" status="dsspStatus">
                       <s:form action="CapNhatSP.action?MaSP=%{MaSP}" method="POST" theme="simple">
                         <table width="100%;" border="1" id="khachhang">
                             <tr>
                                 <td>
                                     <p style="background-color: #4a4a4a;color: #0099ff;">Mã sản phẩm</p>
                                 </td>
                                 <td>
                                     <s:property value="maSP" />
                                 </td>
                                 <td>
                                     <p style="background-color: #4a4a4a;color: #0099ff;">Tên sản phẩm</p>
                                 </td>
                                 <td>
                                     <s:textfield name="TenSP" theme="simple" value="%{tenSP}"></s:textfield>
                                 </td>
                                  <td>
                                     <p style="background-color: #4a4a4a;color: #0099ff;">Giá mua</p>
                                 </td>
                                 <td>
                                     <s:textfield name="GiaMua" theme="simple" value="%{giaMua}"></s:textfield>
                                 </td>
                             </tr>
                              <tr>
                                 <td>
                                     <p style="background-color: #4a4a4a;color: #0099ff;">Giá bán</p>
                                 </td>
                                 <td>
                                      <s:textfield name="GiaBan" theme="simple" value="%{giaBan}"></s:textfield>
                                 </td>
                                 <td>
                                     <p style="background-color: #4a4a4a;color: #0099ff;">Loại sản phẩm</p>
                                 </td>
                                 <td>
                                     <s:select value='%{loaiSP}' list="#{'0':'Áo Thun', '1':'Áo SơMi', '2':'Áo Khoác','3':'Quần jean','4':'Áo kaki','5':'Váy'}" name = "LoaiSP" cssStyle="width:142px" theme="simple" />
                                 </td>
                                  <td>
                                     <p style="background-color: #4a4a4a;color: #0099ff;">Chủ đề</p>
                                 </td>
                                 <td>
                                     <s:select value='%{chuDe}' list="#{'0':'Nổi bật', '1':'Mới', '2':'Khuyến Mãi'}" name = "ChuDe" cssStyle="width:142px" theme="simple"/>
                                 </td>
                             </tr>
                             <tr>
                                 <td>
                                     <p style="background-color: #4a4a4a;color: #0099ff;">Giới tính</p>
                                 </td>
                                 <td>
                                      <s:select value='%{gioiTinh}'list="#{'0':'Nữ', '1':'Nam'}" name = "GioiTinh" cssStyle="width:142px" theme="simple" />
                                 </td>
                                
                                  <td >
                                     <p style="background-color: #4a4a4a;color: #0099ff;">Hình ảnh</p>
                                 </td>
                                 <td colspan="3">
                                     <s:textfield name="HinhAnh" theme="simple" value="%{hinhAnh}" cssStyle="width:100%;"></s:textfield>
                                 </td>
                             </tr>
                             <tr>
                                 <td>
                                     <p style="background-color: #4a4a4a;color: #0099ff;">Thông tin</p>
                                 </td>
                                 <td colspan="3">
                                     <s:textarea name="ThongTin" theme="simple" value="%{thongTin}" cssStyle="width:100%;"></s:textarea>
                                 </td>
                                     <s:url id = "xoa" action="XoaSanPham">
                                         <s:param name = "GiaTriTim" value="MaSP"></s:param>
                                         <s:param name = "gtTimKiem" value="gtTimKiem"></s:param>
                                         <s:param name = "chon" value="chon"></s:param>
                                     </s:url>
                                 <td>
                                     <s:a href="%{xoa}"><img width="40px;" height="40px;" alt="Xóa" title="Xóa" src="images/delete.png" /></s:a>
                                 </td>
                                 <td>
                                     <s:hidden name = "chon" value="%{chon}"></s:hidden>
                                     <s:hidden name = "gtTimKiem" value="%{gtTimKiem}"></s:hidden>
                                     <s:submit name="btnCapNhat" value="Cập nhật" theme="simple"></s:submit>
                                 </td>
                             </tr>
                             <tr>
                                 <td colspan="6" bgcolor="black" height="10px">

                                 </td>
                             </tr>
                         </table>
                     </s:form>
                     </s:iterator>
                     </div>
                          
                 </div>
                 <div style="clear: both;"></div>
                 <jsp:include page="template/footer.jsp"></jsp:include>
             </div>
        </div>
    </body>
</html>
